<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机点名器</title>
</head>

<body>
    <p>张三</p></p>
    <button>开始</button>
</body>
<script>
    let btn = document.querySelector('button');
    let text = document.querySelector('p');
    let names = ['余俊杰', '王美丽', '王浩', '汪涵', '付金恒', '肖足'];
    let timer;
    btn.onclick = function () {
        if (btn.innerHTML == '开始') {
            timer = setInterval(() => {
                text.innerHTML = names[parseInt((Math.random()) * names.length)];
            }, 100);
        } else {
            clearInterval(timer);
        }
        btn.innerHTML = btn.innerHTML.trim() == '开始' ? '暂停' : '开始';
    }
</script>

</html>